'use strict'

class value {

  constructor (mdb) {
    this.db = mdb
    this.tableName = 'getvalue'
  }

  model () {
    return this.db.model(this.tableName)
  }
  
  makeId () {
    return `u_${Date.now().toString(16)}${parseInt(Math.random()*10000) + 11111}`
  }

  async list () {
    let ulist = await this.model().limit(20).select()
    return ulist.rows
  }

  async update (data,getvalueid) {
    await this.model().limit(20).where({getvalueid}).update(data)    
  }
  
  async insert(data){
    data.getvalueid=this.makeId()
    await this.model().insert(data)
  }

}

module.exports = value